package com.hinnotek.amoeba.adapters.old

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.*
import com.bumptech.glide.Glide
import com.hinnotek.amoeba.R

class PurchaseDetailImageViewAdapter(private val mContext: Context, var imageList: List<String>) :
    BaseAdapter() {
    override fun getCount(): Int {
        return imageList.size
    }

    override fun getItem(position: Int): Any {
        return imageList[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View, parent: ViewGroup): View {
        var convertView = convertView
        var viewHolder: ViewHolder? = null
        if (viewHolder == null) {
            viewHolder = ViewHolder()
            convertView = LayoutInflater.from(mContext)
                .inflate(R.layout.item_purchase_detail_image, parent, false)
            viewHolder.imageView = convertView.findViewById<ImageView>(R.id.iv_image)
            convertView.tag = viewHolder
        } else {
            viewHolder = convertView.tag as ViewHolder
        }
        Glide.with(mContext).load(R.mipmap.ic_launcher).into(viewHolder.imageView!!)
        return convertView
    }

    inner class ViewHolder {
        var imageView: ImageView? = null
    }
}